package leetcode;
//选拔赛母牛的故事递归，数学规律
import java.util.Scanner;

/**
 * @author :chenjie
 * @date :Created 2022/11/19 8:56
 */
public class CowProduction {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while (true){
            int n=sc.nextInt();
            if(n==0){
                break;
            }
            int x=1,i=1,sum=1;
            while (x<n){
                x++;
                if((x-2)%3==0&&x>2){
                    i=i*2;
                    System.out.println("生小牛l");
                }
                System.out.println((x-2)%3+1+"年有可生产母牛数"+i);
                sum+=i;

            }
            System.out.println(sum);
        }
    }

}
